﻿using Microsoft.Extensions.DependencyInjection;

namespace System;

public static class BasicExtension
{
    public static IServiceCollection AddBasicMemoryCache(this IServiceCollection services)
    {
        services.AddMemoryCache();
        return services;
    }

    /// <summary>
    /// 获取对象的指定特性
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static T? GetAttribute<T>(this object obj) where T : Attribute
    {
        Type type = obj.GetType();
        return type.GetCustomAttribute<T>();
    }

}
